package org.example.lease.service.dutyhandler.loginduty;

import org.example.lease.vo.login.LoginVo;

/**
 * 抽象登录处理器
 */
public abstract class AbstractLoginHandler implements LoginHandler {
    protected LoginHandler nextHandler;

    @Override
    public LoginHandler setNext(LoginHandler nextHandler) {
        this.nextHandler = nextHandler;
        return nextHandler;
    }

    @Override
    public String handle(LoginVo loginVo) {
        String result = doHandle(loginVo);
        if (result != null) {
            return result;
        }
        if (nextHandler != null) {
            return nextHandler.handle(loginVo);
        }
        return null;
    }

    /**
     * 具体的处理逻辑
     *
     * @param loginVo 登录信息
     * @return 处理结果
     */
    protected abstract String doHandle(LoginVo loginVo);
}